//
// Created by ct on 2020/10/10.
//

#ifndef HTTPSERVER_REPLY_H
#define HTTPSERVER_REPLY_H

#include <string>
#include <vector>
#include <boost/asio.hpp>
#include "header.h"

namespace http {
    namespace server {
        /// 要发送给客户的答复。
        struct reply {
            /// 答复的状态.
            enum status_type {
                ok = 200,
                created = 201,
                accepted = 202,
                no_content = 204,
                multiple_choices = 300,
                moved_permanently = 301,
                moved_temporarily = 302,
                not_modified = 304,
                bad_request = 400,
                unauthorized = 401,
                forbidden = 403,
                not_found = 404,
                internal_server_error = 500,
                not_implemented = 501,
                bad_gateway = 502,
                service_unavailable = 503
            } status;
            /// 要包含在答复中的头。
            std::vector<header> headers;
            /// 回复中要发送的内容。
            std::string content;
            /// 将应答转换为缓冲区向量。缓冲区不拥有
            /// 因此，应答对象必须保持有效，并且
            /// 写入操作完成后才能更改。
            std::vector<boost::asio::const_buffer> to_buffers();
            /// 得到肯定的答复
            static reply stock_reply(status_type status);
        };
    } // namespace server
} // namespace http
#endif //HTTPSERVER_REPLY_H
